#! /usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division

import subprocess

try:
    nbsim = 1000
    ps = [4, 8, 16, 32]
    for i, p in enumerate(ps):
        subprocess.call(["python", "launchToy.py", "--p=%i" % p, "--nbsim=%i" % nbsim])
    bs = [10, 20]
    for i, b in enumerate(bs):
        subprocess.call(["python", "launchToy.py", "--p=16", "--b=%i" % b, "--nbsim=%i" % nbsim])
except:
    print "Error while launching the main program: is scipy.weave functional? try to launch 'python launch.py' \
            and see what is said."

try:
    subprocess.call(["R", "CMD", "BATCH", "--vanilla", "comparisonPermutations.R", "Permut-out.out"])
    subprocess.call(["R", "CMD", "BATCH", "--vanilla", "comparisonIS.R", "IS-out.out"])
    subprocess.call(["R", "CMD", "BATCH", "--vanilla", "comparisonRB.R", "RB-out.out"])
except:
    print "Error while plotting: is R installed? And the ggplot2 library?"


